package com.journey.web.controller;

import com.journey.api.user.service.IUserService;
import com.journey.model.common.ServerResponse;
import com.journey.model.entity.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * Created by ADMIN on 2018/3/16.
 */
@Controller
@RequestMapping("/user")
@SessionAttributes("user")
public class UserController {
    private static final Logger logger = LoggerFactory.getLogger(UserController.class);
    @Qualifier("userService")
    @Autowired
    IUserService userService;

    @RequestMapping("/login")
    @ResponseBody //将NoteResult转成json输出
    public ServerResponse<String> login (String name, String pwd){
        //调用业务组件处理
        ServerResponse<String> response = userService.checkLogin(name, pwd);
        return response;
    }


    @RequestMapping(value = "/regist" , method = RequestMethod.POST)
    @ResponseBody
    public ServerResponse<User> regist (String name, String pwd , String nickname) {
        ServerResponse<User> response = userService.regist(name , pwd , nickname);
        return response;
    }
}
